<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>修改资料</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,minimum-scale=1,maximum-scale=1" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="stylesheet" type="text/css" href="__CSS__/main.css" />
	<script type="text/javascript" src="__COMMON__/jquery.min.js"></script>
</head>
<body class="bg02">
   <div  class="header"> 
      <div class="center">
          <div class="member"><span>贝云CMS</span>|<span class="fl38">会员中心</span></div>
	      <div class="fr">您好，<a class="fr20">刘伟</a> |<a class="fl20 fr20">退出</a>|<a class="fl20">首页</a></div>
     </div>
   </div>
   <div  class="wrapper"> 
      <div class="lft">
        {include file="public/left" /} 
     </div>
      <div class="rgt">
          <div class="tit"></div>
	      		<div class="info_div f12">
				<form action="{:U('update')}"  id="member" method="post">	
				<div class="con">
						<p class="tip f15">亲爱的 <span{$UcenterMember.username|default=""}</span>，填写真实的资料，有助于好友找到你哦。</p>
						<div class="tx">
							<div class="l_txt fl"><span></span>当前头像：</div>
							<div class="pic fl"><img class="upload_img" src="{$UcenterMember.cover_id|get_cover_path}"/></div>
							<span   class="modify" id="cover_id" style="float:left">上传<input type="file" class="upload_file" id="uploads"/></span>
								<input type="hidden" name="cover_id"  value="{$UcenterMember.cover_id|default=''}"	>
						    </div>
										<script type="text/javascript">  
						                 	var upload_url = "{:url('uploads/picture')}";	
											  window.onload = function(){  

												document.getElementById('cover_id').onchange = function(event){  
													var img = event.target.files[0];   
													if(!img){  
														return false;  
													}  
													if(!(img.type.indexOf('image')==0 && img.type && /\.(?:jpg|png|gif)$/.test(img.name)) ){  
														alert('图片只能是jpg,gif,png');  
														return ;  
													}  
													var reader = new FileReader();  
													reader.readAsDataURL(img);  
											  
													reader.onload = function(e){  
														$.post(upload_url, { img: e.target.result},function(ret){  
															if(ret){  
															   $("input[name='cover_id']").val(ret.id);
																   $('.upload_img').attr('src',ret.src);  
															}else{  
																alert('upload fail');  
															}  
														},'json');  
													} 
												}  
											  
                               }  
                          </script>	
						<div class="nc">
							<div class="l_txt fl"><span>*</span>昵称：</div>
							<div class="r_div fl">
								<input type="text" name="nickname" value="{$UcenterMember.username|default=""}" />
								<p class="xz">*昵称填写须知：与买家或卖家品牌冲突的昵称，商城将有可能收回</p>
							</div>
						</div>
						<div class="name">
							<div class="l_txt fl"><span></span>手机号：</div>
							<div class="r_div fl">
								<input type="text" name="mobile" value="{$UcenterMember.mobile|default=""}" />
							</div>
						</div>
						

						<div class="gender">
							<div class="l_txt fl"><span>*</span>性别：</div>
							<div class="r_div fl">
								<div class="male fl"><select name="sex" id="" class="sel fl">
										    
								<option value="男">男</option>
									<option value="女">女</option>
									<option value="保密">保密</option>
									</select></div>
								<div class="female fl"></div>
							</div>
						</div>
                   </br>
					
				
							<a  class="save f14">保存</a>
					</div>
				
				</div>
				<input type="hidden" name="id" value="{$UcenterMember.id|default=""}" />
				</form></div>
      </div>
   </div>
 
</body>
 <script type="text/javascript">
	$("select[name='star']").val("{$UcenterMember.star|default='0'}");
	$("select[name='sex']").val("{$UcenterMember.sex|default='保密'}");	
    	$(".save").click(function(){
    		var self = $("#member");
    		$.post(self.attr("action"),self.serialize(),success,"json");
    		return false;

    		function success(data){
    			if(data.code){
    				alert(data.msg);
    			} else {
				     alert(data.msg)
    			}
    		}
    	});
	</script>
</html>